<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/c" prefix="c" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net/el"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="com.solution.webconstant.PermissionConstants" %>

<%
	HashMap permissionMap = ((HashMap)(session.getAttribute("userPermissionsInfo")));
%>
<script language="JavaScript">
function fnSearch()
{
	document.questionForm.action='/searchQuestion.do?';
	document.questionForm.submit();
}
function fnEditViewQuestionDetails(question_id_value, screen_type_value){
	document.questionForm.screen_type.value=screen_type_value;
	document.questionForm.question_id.value=question_id_value;
	document.questionForm.action='/editViewQuestion.do?';
	document.questionForm.submit();
}
function clearForm(formObj){
	var elements = formObj.elements;
	for(i=0; i<elements.length; i++){
		if(elements[i].type == "text")
			elements[i].value = "";
		if(elements[i].type == "select-one" || elements[i].type == "select-multiple")
			elements[i].selectedIndex = 0;
	}
}
</script>
<html:form action="/searchQuestion">
	<html:hidden property="show_list" />
	<html:hidden property="screen_type" />
	<html:hidden property="question_id" />
	<table width="90%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
 			<td class="heading1">Question Search Form</td>
		</tr>
		<tr>
			<td valign="top">&nbsp;</td>
		</tr>
		<tr>
			<td valign="top"><jsp:include page="showErrorMessage.jsp"/></td>
		</tr>
	  	<tr>
			<td>
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
						<td align="left" valign="top" class="inputtext">Category</td>
						<td  valign="middle">
            				<html:select property="question_category_id" styleId="question_category_id" styleClass="form3">
								<html:option value="">--Please Select--</html:option>
								<logic:present name="questionForm" property="categories">
								<logic:iterate name="questionForm" property="categories" id="category" >
								<bean:define id="dID" name="category" property="id" />
								<html:option  value="<%=dID.toString()%>"><bean:write name="category" property="name"/></html:option>						
								</logic:iterate>
								</logic:present>	
							</html:select>
						</td>
						<td align="left" valign="top" class="inputtext">Difficulty Level</td>
						<td  valign="middle">
            				<html:select property="question_level_id" styleId="question_level_id" styleClass="form3">
								<html:option value="">--Please Select--</html:option>
								<logic:present name="questionForm" property="levels">
								<logic:iterate name="questionForm" property="levels" id="level" >
								<bean:define id="dID" name="level" property="id" />
								<html:option  value="<%=dID.toString()%>"><bean:write name="level" property="name"/></html:option>						
								</logic:iterate>
								</logic:present>	
							</html:select>
						</td>
					</tr>
					<tr>
						<td align="left" valign="top" class="inputtext">Status</td>
						<td valign="middle">
							<html:select styleClass="form3" styleId="question_status" property="question_status" style=":width=72%">
								<html:option value="">--Please Select--</html:option>
								<html:option value="2">Active</html:option>
								<html:option value="3">InActive</html:option>
							</html:select>
						</td>
					</tr>
  					<tr>
						<td height="25" colspan="4" valign="top">&nbsp;</td>
					</tr>
					<tr>
						<td colspan="4" valign="top"  bgcolor="#CCCCCC"><img src="images/zero.gif" width="1" height="1" /></td>
					</tr>
					<tr>
						<td height="25" colspan="4" align="center" valign="top" >&nbsp;</td>
					</tr>
					<tr>
       	 				<td height="25" colspan="4" align="center" valign="top">
       	 					<input type="button" class="imageButton" value="Search" onClick="JavaScript:fnSearch()">
       	 					<input type="button" class="imageButton" value="Reset" onClick="JavaScript:clearForm(this.form)">
       	 				</td>
      				</tr>
      				<tr>
						<td height="25" colspan="4" align="center" valign="top" >&nbsp;</td>
					</tr>
				</table>
          	</td>
		</tr>
		<tr>
			<td>
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
					<logic:equal name="questionForm" property="show_list" value="Y">
					<tr>
						<td>
							<display:table name="questionForm.question_list" decorator="com.solution.decorator.QuestionDecorator"
								export="false"	requestURI="/searchQuestion.do" cellspacing="0" cellpadding="0"
								pagesize="10" class="results" id="question">
								<display:column property="id" title="Code" />
								<display:column property="questionStatement" title="Question" />
								<display:column property="categoryType.name" title="Category" />
								<display:column property="levelType.name" title="Level" />
								<logic:present property="status" name="question">
								<bean:define id="displayStatus" property="status" name="question"/>
								<display:column title="Status"><bean:message key="<%="Status."+displayStatus%>"/></display:column>
								</logic:present>
								<logic:equal name="questionForm" property="screen_type" value="Edit">
									<display:column property="actionEdit" title="Action" />
								</logic:equal>
								<logic:equal name="questionForm" property="screen_type" value="View">
									<display:column property="actionView" title="Action" />
								</logic:equal>
								<display:setProperty name="basic.msg.empty_list">&nbsp;</display:setProperty> 
							</display:table>
						</td>
            		</tr>
            		</logic:equal>
          		</table>
          	</td>
		</tr>
      </table>
</html:form>